package com.gitee.l0km.beanfilter.core;

/**
 * 字段过滤器接口
 * @author guyadong
 */
public interface IFieldFilter extends IFilter{
	/**
	 * 过滤类的指定字段，为{@code true}通过，为{@code false}不允许序列化反序列化
	 * @param clazz 类
	 * @param fieldName 字段名
	 * @return true if the property will be included, false if to be filtered out
	 */
	boolean permit(Class<?>clazz,String fieldName);
	final IFieldFilter DEFAULT_INSTANCE = new DefaultFieldFilter();
	public static final class DefaultFieldFilter implements IFieldFilter {
		@Override
		public boolean permit(Class<?> clazz, String fieldName) {
			return true;
		}
		@Override
		public int hashCode() {
			return getClass().hashCode();
		}
		@Override
		public boolean equals(Object obj) {
			if (this == obj)
				return true;
			if (obj == null)
				return false;
			return getClass() == obj.getClass();
		}};
}
